package org.come.Jpanel;

import com.updateNew.MyIsif;
import org.come.entity.Mount;
import org.come.until.Util;

import javax.swing.*;
import java.awt.*;
import java.util.Map;



class MyRendererXIAO extends JPanel implements ListCellRenderer
{
    private int index;
    public static String vs;
    private Object value;
    private Map<String, Integer> map;
    private boolean isSelected;
    private static DefaultListModel<String> listModel;

    public MyRendererXIAO() {
    }

    public MyRendererXIAO(final int index, final Object value, final boolean isSelected) {
        this.index = index;
        this.isSelected = isSelected;
        this.value = value;
    }

    @Override
    public Dimension getPreferredSize() {
        return new Dimension(this.getWidth(), 24);
    }

    @Override
    public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
        final MyRendererXIAO mr = new MyRendererXIAO(index, value, isSelected);
        mr.removeAll();
        if (mountJPanel.idx2 == index || isSelected) {
            mr.setBackground(Color.GRAY);
        }
        else {
            mr.setOpaque(false);
        }
        mr.setLayout(new FlowLayout(0));
        final Box box = Box.createHorizontalBox();
        mr.add((Component)box);
        return (Component)mr;
    }

    @Override
    protected void paintComponent(final Graphics g) {
        super.paintComponent(g);
        final Graphics2D g2d = (Graphics2D)g;
        if("水墨UI".equals(MyIsif.getStyle())) {
            g2d.setColor(new Color(250, 250, 250));
            final ImageIcon peiimg = new ImageIcon("skin/8100226/newbutton/K158.png");
            g.drawImage(peiimg.getImage(), 1, 3, 34, 17, null);
        }else{
            g2d.setColor(new Color(187, 165, 75));
            final ImageIcon peiimg = new ImageIcon("inkImg/hongmu/1/ss661.png");
            g.drawImage(peiimg.getImage(), 1, 3, 34, 17, null);
        }
        g2d.setFont(new Font("宋体", 0, 12));
        final int index1 = ((Mount)ZhuJpanel.getListMount().get(this.index)).getMountid().intValue();
        g2d.drawString(Util.number2Chinese(index1) + "座", 5, 15);
        g2d.setFont(new Font("宋体", 0, 12));
        if (this.isSelected) {
            g2d.setColor(Color.green);
            g2d.drawString(this.value + "", 40, 16);
        }
        else {
            g2d.setColor(Color.white);
            g2d.drawString(this.value + "", 40, 16);
        }
    }

}
